package com.hepinghospital.user.ui.activity.home;

import android.content.Context;
import android.os.Bundle;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager.widget.ViewPager;

import com.google.android.material.tabs.TabLayout;
import com.hepinghospital.user.R;
import com.hepinghospital.user.base.BaseActivity;
import com.hepinghospital.user.ui.fragment.BookDoctorByDateFragment;
import com.hepinghospital.user.ui.fragment.BookDoctorByNameFragment;

import org.jetbrains.annotations.NotNull;

import java.util.Objects;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by HP on 2020/2/20.
 */

@Deprecated
public class BookDoctorActivity extends BaseActivity {


    @BindView(R.id.timeline_tablayout)
    TabLayout mTabLayout;
    @BindView(R.id.timeline_viewpager)
    ViewPager mViewPager;

    String deptId;

    @Override
    protected void initViews() {
        mViewPager.setAdapter(new DoctorFragmentAdapter(this, getSupportFragmentManager()));
        mTabLayout.setupWithViewPager(mViewPager);

        mViewPager.setCurrentItem(0);
        Objects.requireNonNull(mTabLayout.getTabAt(0)).select();
    }

    @Override
    protected void initData() {

    }

    @OnClick(R.id.btn_search)
    void btn_search() {
        Bundle bundle = new Bundle();
        bundle.putInt("type", 3);
        startActivity(SearchDoctorActivity.class, bundle);
    }

    @Override
    protected int getLayoutResource() {
        return R.layout.activity_book_doctor_online;
    }


    static class DoctorFragmentAdapter extends FragmentPagerAdapter {

        private static final int PAGE_COUNT = 1;

        DoctorFragmentAdapter(Context context, FragmentManager fm) {
            super(fm);
        }

        @NotNull
        @Override
        public Fragment getItem(int position) {
            switch (position) {
                case 0:
                    return BookDoctorByDateFragment.newInstance();
                case 1:
                    return BookDoctorByNameFragment.newInstance();
                default:
                    return BookDoctorByNameFragment.newInstance();
            }
        }

        @Override
        public int getCount() {
            return PAGE_COUNT;
        }

        @Override
        public CharSequence getPageTitle(int position) {
            switch (position) {
                case 0:
                    return "云门诊";
                case 1:
                    return "院内挂号";
                default:
                    return "云门诊";
            }
        }

    }

}
